//
//  BaseTableViewCell.m
//  OAProject
//
//  Created by yhj on 2017/3/16.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "BaseTableViewCell.h"

@interface BaseTableViewCell ()

// 箭头
//@property(nonatomic,strong)UIImageView *imageView;

//// 名字
//@property(nonatomic,strong)UILabel *nameLabel;
//
//// 合同状态
//@property(nonatomic,strong)UILabel *detailLabel;

// 箭头
//@property(nonatomic,strong)UIImageView *arrow_imageView;

@end

@implementation BaseTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        // ➡️Cell类型
        self.accessoryType=UITableViewCellAccessoryNone;

        self.imageView.hidden=NO;

        _image.image=[UIImage imageNamed:@"arrow"];

        self.nameLabel.font=Font_Number(13);

        self.detailLabel.font=Font_Number(11);

        self.backgroundColor=WhiteColor;

        UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapEvent)];
        [self addGestureRecognizer:tap];

        _arrow_imageView.image=[UIImage imageNamed:@"next_arrow"];

    }
    return self;
}

-(void)tapEvent
{
    if (self.delegate&&[self.delegate respondsToSelector:@selector(tapClickNext)])
    {
        [self.delegate tapClickNext];
    }
}


// imageView
-(UIImageView *)image
{
    if (!_image) {
        _image=[UIImageView new];
        [self.contentView addSubview:_image];
        [_image mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin*2);
            make.centerY.mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(kmargin*3,kmargin*3));
        }];
    }
    return _image;
}


// nameLabel
- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel=[self getLabelWithText:@"标题" font:Font_Number(13) textColor:DarkGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.image.mas_right).offset(kmargin);
            make.top.mas_equalTo(self.image.mas_top);
        }];
    }
    return _nameLabel;
}

// detailLabel
- (UILabel *)detailLabel
{
    if (!_detailLabel) {
        _detailLabel=[self getLabelWithText:@"副标题" font:Font_Number(11) textColor:LightGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_detailLabel];
        [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(kmargin/2);
        make.left.mas_equalTo(self.nameLabel.mas_left);
        }];
    }
    return _detailLabel;
}

// arrow_imageView
-(UIImageView *)arrow_imageView
{
    if (!_arrow_imageView) {
        _arrow_imageView=[UIImageView new];
        [self.contentView addSubview:_arrow_imageView];
        [_arrow_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-kmargin*2);
            make.centerY.mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(kmargin*3/2,kmargin));
        }];
    }
    return _arrow_imageView;
}


@end
